package com.share.shareplatform.util;

import com.share.shareplatform.pojo.exception.LogicException;

import java.util.ArrayList;
import java.util.List;

public class StringUtils {
    public static List<Long> splitStringToLongList(String ids){
        try{
            String[] stringIds=ids.split("-");
            ArrayList<Long> arrayList=new ArrayList<>();
            for(String id:stringIds){
                arrayList.add(Long.parseLong(id));
            }
            return arrayList;
        }catch (Exception e){
            throw new LogicException("id的格式有误,只能是id-id-id这种形式");
        }

    }

    public static String getUrlModule(String url){
        int i;
        for(i=1;i<url.length();i++){
            if(url.charAt(i)=='/'||url.charAt(i)=='\\'){
                break;
            }
        }
        return url.substring(1,i);
    }
}
